package jpa_objects;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.MappedSuperclass;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import org.hibernate.mapping.Array;

/**
 * @author Alejandro Casas
 * @version 1.0
 * @created 10-Dec-2012 1:01:03 AM
 */
@Entity
@NamedQuery(name="searchUsers", query="SELECT u FROM User u WHERE u.name LIKE  :string " +
" OR u.mail LIKE  :string ")
@Inheritance(strategy=InheritanceType.JOINED)
public class User {

	private String carrier;
	private String country;
	private City city;
	private String description;
	private long id;
	private String joinDate;
	
	private String miniPicture;
	private String name;
	private int num_ratings;
	private String password;
	private String phone;
	private String picture;
	private double rating;
	private String status;
	private List<Notification> notifications;
	private List<Business> following_businesses;
	private List<Instructor> following_instructors;
	private List<Event> event_history;
	private List<Event> events;
	//Reviews eliminar 
	private List<Review> reviews;
	//--------------
	private List<Message> received;
	private List<Message> sent;
	private List<Sport> sports_of_interest;
	private String mail;
	
	/**
	 * @return the reviews
	 * Reviews eliminar 
	 */
	@OneToMany(targetEntity=Review.class,cascade=CascadeType.ALL)
	public List<Review> getReviews() {
		return reviews;
	}

	/**
	 * @param reviews the reviews to set
	 * Reviews eliminar 
	 */
	public void setReviews(List<Review> reviews) {
		this.reviews = reviews;
	}

	/**
	 * @return the mail
	 */
	@Id
	public String getMail() {
		return mail;
	}

	/**
	 * @param mail the mail to set
	 */
	public void setMail(String mail) {
		this.mail = mail;
	}
	
	

	/**
	 * @return the sports_of_interest
	 */
	@OneToMany(targetEntity=Sport.class,cascade=CascadeType.ALL)
	public List<Sport> getSports_of_interest() {
		return sports_of_interest;
	}

	/**
	 * @param sports_of_interest the sports_of_interest to set
	 */
	public void setSports_of_interest(List<Sport> sports_of_interest) {
		this.sports_of_interest = sports_of_interest;
	}

	/**
	 * @param carrier
	 * @param country
	 * @param description
	 * @param joinDate
	 * @param mail
	 * @param miniPicture
	 * @param name
	 * @param num_ratings
	 * @param password
	 * @param phone
	 * @param picture
	 * @param rating
	 * @param status
	 */
	public User(String carrier, String country, String description,
			String joinDate, String mail, String miniPicture, String name,
			int num_ratings, String password, String phone, String picture,
			double rating, String status,City city) {
		this.carrier = carrier;
		this.country = country;
		this.description = description;
		this.joinDate = joinDate;
		//this.mail = mail;
		this.miniPicture = miniPicture;
		this.name = name;
		this.num_ratings = num_ratings;
		this.password = password;
		this.phone = phone;
		this.picture = picture;
		this.rating = rating;
		this.status = status;
		this.mail=mail;
		notifications=new ArrayList<Notification>();
		following_businesses=new ArrayList<Business>();
		following_instructors=new ArrayList<Instructor>();
		event_history=new ArrayList<Event>();
		events= new ArrayList<Event>();
		this.reviews=new ArrayList<Review>();
		received=new ArrayList<Message>();
		sent=new ArrayList<Message>();
		this.city=city;
		sports_of_interest=new ArrayList<Sport>();
		
	}

	/**
	 * @return the city
	 */
	@OneToOne(targetEntity=City.class,cascade=CascadeType.ALL)
	public City getCity() {
		return city;
	}

	/**
	 * @param city the city to set
	 */
	public void setCity(City city) {
		this.city = city;
	}
	/**
	 * @return the carrier
	 */
	public String getCarrier() {
		return carrier;
	}

	/**
	 * @param carrier the carrier to set
	 */
	public void setCarrier(String carrier) {
		this.carrier = carrier;
	}

	/**
	 * @return the country
	 */
	public String getCountry() {
		return country;
	}

	/**
	 * @param country the country to set
	 */
	public void setCountry(String country) {
		this.country = country;
	}

	/**
	 * @return the description
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the id
	 */

	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the joinDate
	 */
	public String getJoinDate() {
		return joinDate;
	}

	/**
	 * @param joinDate the joinDate to set
	 */
	public void setJoinDate(String joinDate) {
		this.joinDate = joinDate;
	}

	/**
	 * @return the mail
	 *
	@Id
	public String getMail() {
		return mail;
	}

	/**
	 * @param mail the mail to set
	 *
	public void setMail(String mail) {
		this.mail = mail;
	}

	/**
	 * @return the miniPicture
	 */
	public String getMiniPicture() {
		return miniPicture;
	}

	/**
	 * @param miniPicture the miniPicture to set
	 */
	public void setMiniPicture(String miniPicture) {
		this.miniPicture = miniPicture;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the num_ratings
	 */
	public int getNum_ratings() {
		return num_ratings;
	}

	/**
	 * @param num_ratings the num_ratings to set
	 */
	public void setNum_ratings(int num_ratings) {
		this.num_ratings = num_ratings;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @param phone the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * @return the picture
	 */
	public String getPicture() {
		return picture;
	}

	/**
	 * @param picture the picture to set
	 */
	public void setPicture(String picture) {
		this.picture = picture;
	}

	/**
	 * @return the rating
	 */
	public double getRating() {
		return rating;
	}

	/**
	 * @param rating the rating to set
	 */
	public void setRating(double rating) {
		this.rating = rating;
	}

	/**
	 * @return the status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	/**
	 * @return the notifications
	 */
	@OneToMany(targetEntity=Notification.class,cascade=CascadeType.ALL)
	public List<Notification> getNotifications() {
		return notifications;
	}

	/**
	 * @param notifications the notifications to set
	 */
	public void setNotifications(List<Notification> notifications) {
		this.notifications = notifications;
	}

	/**
	 * @return the following_businesses
	 */
	@OneToMany(targetEntity=Business.class,cascade=CascadeType.ALL)
	public List<Business> getFollowing_businesses() {
		return following_businesses;
	}

	/**
	 * @param following_businesses the following_businesses to set
	 */
	public void setFollowing_businesses(List<Business> following_businesses) {
		this.following_businesses = following_businesses;
	}

	/**
	 * @return the following_instructors
	 */
	@OneToMany(targetEntity=Instructor.class,cascade=CascadeType.ALL)
	public List<Instructor> getFollowing_instructors() {
		return following_instructors;
	}

	/**
	 * @param following_instructors the following_instructors to set
	 */
	public void setFollowing_instructors(List<Instructor> following_instructors) {
		this.following_instructors = following_instructors;
	}

	/**
	 * @return the event_history
	 */
	@OneToMany(targetEntity=Event.class,cascade=CascadeType.ALL)
	public List<Event> getEvent_history() {
		return event_history;
	}

	/**
	 * @param event_history the event_history to set
	 */
	public void setEvent_history(List<Event> event_history) {
		this.event_history = event_history;
	}

	/**
	 * @return the events
	 */
	@OneToMany(targetEntity=Event.class,cascade=CascadeType.ALL)
	public List<Event> getEvents() {
		return events;
	}

	/**
	 * @param events the events to set
	 */
	public void setEvents(List<Event> events) {
		this.events = events;
	}

	

	/**
	 * @return the received
	 */
	@OneToMany(targetEntity=Message.class,cascade=CascadeType.ALL)
	public List<Message> getReceived() {
		return received;
	}

	/**
	 * @param received the received to set
	 */
	public void setReceived(List<Message> received) {
		this.received = received;
	}

	/**
	 * @return the sent
	 */
	@OneToMany(targetEntity=Message.class,cascade=CascadeType.ALL)
	public List<Message> getSent() {
		return sent;
	}

	/**
	 * @param sent the sent to set
	 */
	public void setSent(List<Message> sent) {
		this.sent = sent;
	}

	public User(){

	}

	public void finalize() throws Throwable {

	}


	
}